﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Reviewer.Entities
{
    [DataContract(Namespace = "Reviewer.Entities")]
    public sealed class FrontPagePost : IExtensibleDataObject
    {
        public static bool operator ==(FrontPagePost item1, FrontPagePost item2)
        {
            // If both are null, or both are same instance, return true.
            if (System.Object.ReferenceEquals(item1, item2))
            {
                return true;
            }

            // If one is null, but not both, return false.
            if (((object)item1 == null) || ((object)item2 == null))
            {
                return false;
            }

            return item1.Equals(item2);
        }
        public static bool operator !=(FrontPagePost item1, FrontPagePost item2)
        {
            return !(item1 == item2);
        }

        [DataMember(IsRequired = true)]
        public int Id { get; set; }
        [DataMember(IsRequired = true)]
        public String Title { get; set; }
        [DataMember]
        public String PostType { get; set; }
        [DataMember]
        public string Link { get; set; }
        [DataMember]
        public string Text { get; set; }
        [DataMember]
        public Int32? ImageId { get; set; }
        [DataMember]
        public DateTime Date { get; set; }
        [DataMember]
        public bool IsActive { get; set; }

        public override bool Equals(object obj)
        {
            FrontPagePost second = obj as FrontPagePost;
            if (second != null)
            {
                return this.Id.Equals(second.Id)
                    && this.Title.Equals(second.Title)
                    && this.PostType.Equals(second.PostType)
                    && this.Link.Equals(second.Link)
                    && this.Text.Equals(second.Text)
                    && this.ImageId.Equals(second.ImageId)
                    && this.Date.Equals(second.Date)
                    && this.IsActive.Equals(second.IsActive)
                    ;
            }
            return false;
        }

        public override int GetHashCode()
        {
            return this.Id.GetHashCode();
        }

        #region IExtensibleDataObject Members
        ExtensionDataObject IExtensibleDataObject.ExtensionData { get; set; }
        #endregion
    }
}
